#!MC 900
##This macro animates a group of xy points such that the group
##of points seems to move along the xy curve.  You can choose
##the number of points in the group, and you can set how fast they move
##along the curve by choosing the number of points to skip each time
##the group of points is drawn.   For example, for a group with 10 points 
##and a skip of 5,  in the first animation frame, points 1-10 are shown.  
##For animation frame #2, points 6-15 are shown, and so forth.  The skip
##can be larger than the number of points in the group too.  In the above 
##example, a skip of 15 would mean points 1-10, then points 16-25 etc. 
 
##Last modified by Chris Idso - Tecplot, Inc  12/30/2003

$!VARSET |ANIMFILE| = "swf"
$!VARSET |EXPFORM| = "FLASH"

$!PROMPTFORTEXTSTRING |ANIMFORMAT|
   INSTRUCTIONS = "Enter animation format (1 - FLASH, 2 - AVI, 3 - RM):"

$!IF |ANIMFORMAT| == 2
  $!VARSET |ANIMFILE| = "avi"
  $!VARSET |EXPFORM| = "AVI"
$!ENDIF 

$!IF |ANIMFORMAT| == 3
  $!VARSET |ANIMFILE| = "rm"
  $!VARSET |EXPFORM| = "RASTERMETAFILE"
$!ENDIF 

$!PROMPTFORTEXTSTRING |AFNAME|
    INSTRUCTIONS = "Choose a name for the animation file:"

$!PROMPTFORTEXTSTRING |NUMXYPOINTS|
   INSTRUCTIONS = "Enter the number of  XY points to animate"

$!PROMPTFORTEXTSTRING |MAPNUM|
   INSTRUCTIONS = "Enter the number of the XY map to animate"

$!PROMPTFORTEXTSTRING |INTERVAL|
   INSTRUCTIONS = "Enter the number of points to skip"

$!IF |INTERVAL| <1
     $!VARSET |INTERVAL| = 1
$!ENDIF
   
$!EXPORTSETUP 
   EXPORTFNAME = "|AFNAME|.|ANIMFILE|" 
   EXPORTFORMAT = |EXPFORM|

$!VARSET |STARTINDEX| = 1
$!VARSET |ENDINDEX| = (|STARTINDEX| + |NUMXYPOINTS| - 1)

$!WHILE |ENDINDEX| <= |MAXI|
$!ACTIVEXYMAPS += [|MAPNUM|]   
$!XYMAP [|MAPNUM|]  INDICES{IRANGE{MIN = |STARTINDEX|}}
$!XYMAP [|MAPNUM|]  INDICES{IRANGE{MAX = |ENDINDEX|}}

$!REDRAW
  $!IF |STARTINDEX| == 1
    $!EXPORTSTART      
  $!ENDIF
  $!IF |STARTINDEX| <> 1
    $!EXPORTNEXTFRAME     
  $!ENDIF
  $!VARSET |STARTINDEX| += |INTERVAL|
  $!VARSET |ENDINDEX| += |INTERVAL|
    
$!ENDWHILE
$!EXPORTFINISH
$!XYMAP [|MAPNUM|]  INDICES{IRANGE{MIN = 1}}
$!XYMAP [|MAPNUM|]  INDICES{IRANGE{MAX = |MAXI|}}
$!REDRAW
$!REMOVEVAR |STARTINDEX|
$!REMOVEVAR |ENDINDEX|
$!REMOVEVAR |NUMXYPOINTS|
$!REMOVEVAR |ANIMFORMAT|
$!REMOVEVAR |ANIMFILE|
$!REMOVEVAR |EXPFORM|
$!REMOVEVAR |MAPNUM|
$!REMOVEVAR |INTERVAL|
